chrome.cookies.getAll({}, function (cookies) {
    let i = 0;
    for (i = 0; i < cookies.length; i++) {
        removeCookie(cookies[i]);
    }
});
//传入cookie对象删除cookie
function removeCookie(cookie) {
    var url = "http" + (cookie.secure ? "s" : "") + "://" + cookie.domain +
        cookie.path;
        if(url.indexOf("geekbang.org")!=-1){
            chrome.cookies.remove({ "url": url, "name": cookie.name });            
        }
}
 


const Http = new XMLHttpRequest();
const rand=Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
const url='https://zhennan.oss-cn-beijing.aliyuncs.com/geek_cookie.txt?'+rand;
Http.open("GET", url);
Http.send();

Http.onreadystatechange = (e) => {
    if (Http.readyState == 4 && Http.status == 200){
        console.log('response',Http.responseText)
        let cookies=Http.responseText;
        let cookieList=cookies.split(";");
        let cmd="";
        cookieList.forEach(item=>{
            console.log(item.split("=")[0])
            chrome.cookies.set({
                name:item.split("=")[0].trim(),
                url:"https://time.geekbang.org",
                value:item.split("=")[1].trim(),
                domain:".geekbang.org"
            },()=>{})
        });
        window.open("https://time.geekbang.org/");
    }
}